package icom.acm.manager.mircblog_mongo;

import icom.acm.bean.mircblog.T_MB_MESSAGE;
import icom.acm.util.mongo.MongoDB;
import icom.acm.util.mongo.FieldMongoType;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

public class T_MB_MessageMongoMgr {
	public void insert(T_MB_MESSAGE e){
		MongoDB dbmongo = MongoDB.newInstance();
		dbmongo.getCollection("T_MB_MESSAGE");
		DBObject obj = e.getDBObject();
		/*obj.put("M_ID", e.getM_ID());
		obj.put("M_U_ID",	 e.getM_U_ID());
		obj.put("M_DATE", e.getM_DATE());
		obj.put("M_CONTENT", e.getM_CONTENT());
		obj.put("MT_M_ID", e.getMT_M_ID());
		obj.put("M_ANNEX()", e.getM_ANNEX());*/
		
		dbmongo.insert(obj);		
	}

	public DBObject findByMid(String msgid, MongoDB dbmongo) {
		BasicDBObject arg = new BasicDBObject();		
		arg = dbmongo.addTerm(arg, "M_ID", 
				FieldMongoType.EQUAL, msgid, 
				FieldMongoType.INTEGER);
		dbmongo.getCollection("T_MB_MESSAGE");
		dbmongo.find(arg);
		DBObject obj = dbmongo.next();	
		//T_MB_MESSAGE e = new T_MB_MESSAGE(obj);
		return obj;
	}
}
